/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.account.Key.AccountBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.DataSource;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.cs.service.account.ToXML;
/*    */ import com.zimbra.soap.JaxbUtil;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import com.zimbra.soap.admin.message.GetDataSourcesRequest;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class GetDataSources
/*    */   extends AdminDocumentHandler
/*    */ {
/* 45 */   private static final String[] TARGET_ACCOUNT_PATH = { "id" };
/*    */   
/* 47 */   protected String[] getProxiedAccountPath() { return TARGET_ACCOUNT_PATH; }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */   public boolean domainAuthSufficient(Map context)
/*    */   {
/* 54 */     return true;
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */   public boolean defendsAgainstDelegateAdminAccountHarvesting()
/*    */   {
/* 62 */     return true;
/*    */   }
/*    */   
/*    */   public Element handle(Element request, Map<String, Object> context) throws ServiceException
/*    */   {
/* 67 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 68 */     Provisioning prov = Provisioning.getInstance();
/* 69 */     GetDataSourcesRequest req = (GetDataSourcesRequest)JaxbUtil.elementToJaxb(request);
/* 70 */     String id = req.getId();
/* 71 */     Account account = prov.get(Key.AccountBy.id, id, zsc.getAuthToken());
/* 72 */     defendAgainstAccountOrCalendarResourceHarvesting(account, Key.AccountBy.id, id, zsc, Rights.Admin.R_adminLoginAs, Rights.Admin.R_adminLoginCalendarResourceAs);
/*    */     
/*    */ 
/* 75 */     Element response = zsc.createElement(AdminConstants.GET_DATA_SOURCES_RESPONSE);
/* 76 */     List<DataSource> sources = Provisioning.getInstance().getAllDataSources(account);
/* 77 */     for (DataSource ds : sources) {
/* 78 */       ToXML.encodeDataSource(response, ds);
/*    */     }
/* 80 */     return response;
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 85 */     relatedRights.add(Rights.Admin.R_adminLoginAs);
/* 86 */     relatedRights.add(Rights.Admin.R_adminLoginCalendarResourceAs);
/* 87 */     notes.add("If the target is an account, need the adminLoginAs right; If the target is a calendar resource, need the R_adminLoginCalendarResourceAs right.");
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/GetDataSources.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */